//
//  LayoutCellAd.m
//  ebook
//
//  Created by 吴超飞 on 2017/3/20.
//  Copyright © 2017年 Moton. All rights reserved.
//

#import "LayoutCellAd.h"
#import "BannerAdView.h"

@interface LayoutCellAd()<BannerAdViewDelegate>

@property (nonatomic,retain) UIViewController *controller;
@property (nonatomic,retain) NSDictionary *adDict;
@property (nonatomic,retain) BannerAdView *bannerAdView;

@end

@implementation LayoutCellAd

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier withDict:(NSDictionary *)dict inController:(UIViewController *)controller{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        _controller = controller;
        _adDict = dict;
    }
    return self;
}

- (void)drawRect:(CGRect)rect {
    
    self.bannerAdView.frame = CGRectMake(0, 0, MTScreenW, kLayoutCellAdHeight);
    [self addSubview:self.bannerAdView];
    [self.bannerAdView loadAd];
}

-(BannerAdView *)bannerAdView{
    
    if (!_bannerAdView) {
        NSDictionary *dict = kBookCityDataDict;
        _bannerAdView = [[BannerAdView alloc]initWithDict:dict[@"ad"][@"search_banner"] adLocation:BannerAdInSearch inController:_controller];
        _bannerAdView.delegate = self;
    }
    return _bannerAdView;
}

+(float)viewHeight:(LayoutType *)layoutType{
    
    return kLayoutCellAdHeight;
}

-(void)bannerAdView:(BannerAdView *)view didLoadBannerAdHeight:(float)height{
    
}

-(void)bannerAdViewClose:(BannerAdView *)view{
    
}

@end
